<!DOCTYPE html>
<!--
     SPDX-License-Identifier: CC-BY-SA-4.0
     SPDX-FileCopyrightText: 2020 seL4 Project a Series of LF Projects, LLC.
-->
<!-- Page last generated 2025-02-20 03:16:15 +0000 -->
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Events in CAmkES | seL4 docs</title>

    <!-- Our stylesheet and theme stylesheet.  Contains bootstrap. -->
    <link rel="stylesheet" href="/assets/css/style.css" type="text/css">
    <!-- Font awesome -->
    <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
    <!-- Pygments syntax highlighting  -->
    <link rel="stylesheet" href="/assets/css/highlighting/trac.css" type="text/css">
    <link rel="icon" type="image/x-icon" href="/assets/favicon.ico"><script defer data-domain="docs.sel4.systems"
	    src="https://analytics.sel4.systems/js/script.js"></script></head>

  <body class="container-fluid">

    



<header>
  <ul class="row menu">
    <li class="col-xs-12 col-md-2" >
            <a href="https://sel4.systems" class="skip-icon">
              <img class="img-responsive" src="/assets/logo-text-white.svg" alt="seL4 logo" />
            </a>
    </li>
    <li class="col-xs-12 col-md-10 menu">
      <nav aria-label="Banner links">
        <h2><a href="/Resources" />Resources</h2>
        <h2><a href="/processes" />Contributing</a></h2>
        <h2><a href="/projects" />Projects</h2>
        <h2><a href="/Tutorials" />Tutorials</h2>
        <iframe title="DuckDuckGo search bar" src="https://duckduckgo.com/search.html?site=docs.sel4.systems&prefill=Search%20sel4.systems" style="overflow:hidden;margin-bottom:10px; padding:0;height:40px;float:right;border-width: 0px"></iframe>
      </nav>
    </li>
  </ul>
  <div class="clear"></div>
  
<div class="breadcrumbs bootstrap hidden-sm-down">
  <nav class="sel-breadcrumb" aria-label="Breadcrumb" >
    <ol class=" list-unstyled" vocab="http://schema.org/" typeof="BreadcrumbList">
      
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/">
              <span property="name"><b>seL4 Docs</b></span>
            </a>
            <meta property="position" content="1" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/Tutorials/">
              <span property="name"><b>Tutorials</b></span>
            </a>
            <meta property="position" content="2" />
        </li>
      
        

        
          <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <span property="name">Events in CAmkES</span>
            <meta property="position" content="3" /></li>
          
    </ol>
  </nav>
  <nav class="sel-version" aria-label="Current Versions">
    <ol class="list-unstyled">
      <li class="list-unstyled text-right" style="margin-left:auto; padding:0rem 0rem;">
        Current versions:</li>
      <li class="list-unstyled text-right">
      <a href="/releases/sel4/13.0.0"><b>seL4-13.0.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/microkit/1.4.1"><b>microkit-1.4.1</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/camkes/camkes-3.11.0"><b>camkes-3.11.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/capdl/0.3.0"><b>capDL-0.3.0</b></a></li>
      </ol>
  </nav>
  <div class='clear'></div>
</div>


</header>

    <main>
      <div class="row">
  <div class="hidden-xs col-sm-4 col-md-3 col-lg-2">
    

<div class="sidebar">
  <ul class="nav nav-sidebar tutorial-sidebar">
    <li class="nav-section">Getting started</li>
      <li><a href="/Tutorials/">Overview</a></li>
      <li><a href="/Tutorials/pathways">Tutorial pathways</a></li>
    <li class="nav-section">seL4</li>
      <li><a href="/Tutorials/setting-up">Setting up your machine</a></li>
      <li><a href="/Tutorials/get-the-tutorials">Getting the tutorials</a></li>
      <li><a href="/Tutorials/hello-world">Hello world</a></li>
      <li><a href="/Tutorials/capabilities">Capabilities</a></li>
      <li><a href="/Tutorials/untyped">Untyped</a></li>
      <li><a href="/Tutorials/mapping">Mapping</a></li>
      <li><a href="/Tutorials/threads">Threads</a></li>
      <li><a href="/Tutorials/ipc">IPC</a></li>
      <li><a href="/Tutorials/notifications">Notifications</a></li>
      <li><a href="/Tutorials/interrupts">Interrupts</a></li>
      <li><a href="/Tutorials/fault-handlers">Fault handling</a></li>
      <li><a href="/Tutorials/mcs">MCS extensions</a></li>
    <li class="nav-section">C Libraries</li>
      <li><a href="/Tutorials/libraries-1">Initialisation &amp; threading</a></li>
      <li><a href="/Tutorials/libraries-2">IPC</a></li>
      <li><a href="/Tutorials/libraries-3">Processes &amp; Elf loading</a></li>
      <li><a href="/Tutorials/libraries-4">Timer</a></li>
    <li class="nav-section">Microkit</li>
      <li><a href="https://trustworthy.systems/projects/microkit/tutorial/">Tutorial</a></li>
    <li class="nav-section">CAmkES</li>
      <li><a href="/Tutorials/hello-camkes-0">Hello CAmkES</a></li>
      <li><a href="/Tutorials/hello-camkes-1">Introduction to CAmkES</a></li>
      <li><a href="/Tutorials/hello-camkes-2">Events in CAmkES</a></li>
      <li><a href="/Tutorials/hello-camkes-timer">CAmkES timer tutorial</a></li>
      <li><a href="/Tutorials/camkes-vm-linux">CAmkES VM</a></li>
      <li><a href="/Tutorials/camkes-vm-crossvm">CAmkES cross-VM connectors</a></li>
    <li class="nav-section">Rust</li>
      <li><a href="https://github.com/seL4/rust-sel4">GitHub</a></li>
    <li class="nav-section">Resources</li>
      <li><a href="https://sel4.systems/Info/Docs/seL4-manual-latest.pdf">seL4 Manual</a></li>
      <li><a href="/projects/sel4/api-doc.html">seL4 API reference</a></li>
      <li><a href="/Tutorials/how-to">How to: a quick solutions guide</a></li>
      <li><a href="/projects/sel4-tutorials/debugging-guide">Debugging guide</a></li>
      <li><a href="/Resources#contact">Help contacts</a></li>
  </ul>
</div>

  </div>
  <div class="content col-sm-8 col-md-6 col-lg-7 main">

    
<!--
  Copyright 2017, Data61, CSIRO (ABN 41 687 119 230)

  SPDX-License-Identifier: BSD-2-Clause
-->

<h1 id="events-in-camkes">Events in CAmkES</h1>
<p>This tutorial shows how to build events in CAmkES.</p>

<p>Learn how to:</p>
<ul>
  <li>Represent and implement events in CAmkES.</li>
  <li>Use Dataports.</li>
</ul>

<p>Use this <a href="https://github.com/seL4/sel4-tutorials/blob/master/docs/CAmkESTutorial.pdf">slide presentation</a> to guide you through the tutorials <a href="/Tutorials/hello-camkes-0">0</a>, <a href="/Tutorials/hello-camkes-1">1</a> and <a href="/Tutorials/hello-camkes-2">2</a>.</p>

<h2 id="prerequisites">Prerequisites</h2>
<ol>
  <li><a href="/Tutorials/setting-up">Set up your machine</a></li>
  <li><a href="/Tutorials/hello-camkes-1">Introduction to CAmkES tutorial</a></li>
</ol>

<h2 id="capdl-loader">CapDL Loader</h2>

<p>This tutorial uses the <em>capDL loader</em>, a root task which allocates statically
 configured objects and capabilities.</p>

<details>
  <summary>Get CapDL</summary>
  <p>The capDL loader parses
a static description of the system and the relevant ELF binaries.
It is primarily used in <a href="https://docs.sel4.systems/CAmkES/">Camkes</a> projects
but we also use it in the tutorials to reduce redundant code.
The program that you construct will end up with its own CSpace and VSpace, which are separate
from the root task, meaning CSlots like <code class="language-plaintext highlighter-rouge">seL4_CapInitThreadVSpace</code> have no meaning
in applications loaded by the capDL loader.
<br />
More information about CapDL projects can be found <a href="https://docs.sel4.systems/CapDL.html">here</a>.
<br />
For this tutorial clone the <a href="https://github.com/sel4/capdl">CapDL repo</a>. This can be added in a directory that is adjacent to the tutorials-manifest directory.</p>
</details>

<h2 id="initialising">Initialising</h2>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># For instructions about obtaining the tutorial sources see https://docs.sel4.systems/Tutorials/get-the-tutorials</span>
<span class="c">#</span>
<span class="c"># Follow these instructions to initialise the tutorial</span>
<span class="c"># initialising the build directory with a tutorial exercise</span>
./init <span class="nt">--tut</span> hello-camkes-2
<span class="c"># building the tutorial exercise</span>
<span class="nb">cd </span>hello-camkes-2_build
ninja
</code></pre></div></div>

<details>
  <summary><em>Hint:</em> tutorial solutions</summary>
  <p><br />
All tutorials come with complete solutions. To get solutions run:</p>

  <div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># For instructions about obtaining the tutorial sources see https://docs.sel4.systems/Tutorials/get-the-tutorials</span>
<span class="c">#</span>
<span class="c"># Follow these instructions to initialise the tutorial</span>
<span class="c"># initialising the build directory with a tutorial exercise</span>
./init <span class="nt">--solution</span> <span class="nt">--tut</span> hello-camkes-2
<span class="c"># building the tutorial exercise</span>
<span class="nb">cd </span>hello-camkes-2_build
ninja
</code></pre></div>  </div>

</details>

<h3 id="specify-an-events-interface">Specify an events interface</h3>
<p>Here you’re declaring the events that will be bounced
back and forth in this tutorial. An event is a signal is sent over a
Notification connection.</p>

<p>You are strongly advised to read the manual section on Events here:
<a href="https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events">https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events</a>.</p>

<p>'’Ensure that when declaring the consumes and emits keywords between
  the Client.camkes and Echo.camkes files, you match them up so that
  you’re not emitting on both sides of a single interface, or consuming
  on both sides of an interface.’’</p>

<h4 id="specify-an-events-interface-1">Specify an events interface</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 1: the event interfaces */
    /* hint 1: specify 2 interfaces: one "emits" and one "consumes"
     * hint 2: you can use an arbitrary string as the interface type (it doesn't get used)
     * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 1: the event interfaces */
    emits TheEvent echo;
    consumes TheEvent client;
</code></pre></div>  </div>

</details>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 3: the event interfaces */
    /* hint 1: specify 2 interfaces: one "emits" and one "consumes"
     * hint 2: you can use an arbitrary string as the interface type (it doesn't get used)
     * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 3: the event interfaces */
    consumes TheEvent echo;
    emits TheEvent client;
</code></pre></div>  </div>
</details>

<h4 id="add-connections">Add connections</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 5: Event connections */
    /* hint 1: connect each "emits" interface in a component to the "consumes" interface in the other
     * hint 2: use seL4Notification as the connector
     * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */
</code></pre></div></div>
<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 5: Event connections */
    connection seL4Notification echo_event(from client.echo, to echo.echo);
    connection seL4Notification client_event(from echo.client, to client.client);
</code></pre></div>  </div>
</details>

<h3 id="data">Data</h3>
<p>Recall that CAmkES prefixes the name
of the interface instance to the function being called across that
interface? This is the same phenomenon, but for events; in the case of a
connection over which events are sent, there is no API, but rather
CAmkES will generate _emit() and _wait() functions to enable the
application to transparently interact with these events.</p>

<h4 id="signal-that-the-data-is-available">Signal that the data is available</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 10: emit event to signal that the data is available */
    /* hint 1: use the function &lt;interface_name&gt;_emit
    * hint 2: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
    */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 10: emit event to signal that the data is available */</span>
    <span class="n">echo_emit</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h4 id="wait-for-data-to-become-available">Wait for data to become available</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 11: wait to get an event back signalling that the reply data is available */
    /* hint 1: use the function &lt;interface_name&gt;_wait
     * hint 2: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */
</code></pre></div></div>
<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 11: wait to get an event back signalling that the reply data is available */</span>
    <span class="n">client_wait</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h4 id="signal-that-data-is-available">Signal that data is available</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 14: emit event to signal that the data is available */</span>
    <span class="cm">/* hint 1: we've already done this before */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 14: emit event to signal that the data is available */</span>
    <span class="n">echo_emit</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h4 id="wait-for-data-to-be-read">Wait for data to be read</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 15: wait to get an event back signalling that data has been read */</span>
    <span class="cm">/* hint 1: we've already done this before */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 15: wait to get an event back signalling that data has been read */</span>
    <span class="n">client_wait</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h4 id="signal-that-data-is-available-1">Signal that data is available</h4>
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 22: notify the client that there is new data available for it */</span>
    <span class="cm">/* hint 1: use the function &lt;interface_name&gt;_emit
    * hint 2: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
    */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 22: notify the client that there is new data available for it */</span>
    <span class="n">client_emit</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h4 id="signal-that-data-has-been-read">Signal that data has been read</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 25: notify the client that we are done reading the data */</span>
    <span class="cm">/* hint 1: use the function &lt;interface_name&gt;_emit
    * hint 2: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
    */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 25: notify the client that we are done reading the data */</span>
    <span class="n">client_emit</span><span class="p">();</span>
</code></pre></div>  </div>
</details>

<h3 id="handle-notifications">Handle notifications</h3>
<p>One way to handle notifications in CAmkES is to
use callbacks when they are raised. CAmkES generates functions that
handle the registration of callbacks for each notification interface
instance. These steps help you to become familiar with this approach.</p>

<h4 id="register-a-callback-handler">Register a callback handler</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 18: register the first callback handler for this interface */</span>
    <span class="cm">/* hint 1: use the function &lt;interface name&gt;_reg_callback()
     * hint 2: register the function "callback_handler_1"
     * hint 3: pass NULL as the extra argument to the callback
     * hint 4: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 18: register the first callback handler for this interface */</span>
    <span class="kt">int</span> <span class="n">error</span> <span class="o">=</span> <span class="n">echo_reg_callback</span><span class="p">(</span><span class="n">callback_handler_1</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
    <span class="n">ZF_LOGF_IF</span><span class="p">(</span><span class="n">error</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="s">"Failed to register callback"</span><span class="p">);</span>
</code></pre></div>  </div>
</details>

<h4 id="register-another-callback-handler">Register another callback handler</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 21: register the second callback for this event. */</span>
  <span class="cm">/* hint 1: use the function &lt;interface name&gt;_reg_callback()
    * hint 2: register the function "callback_handler_2"
    * hint 3: pass NULL as the extra argument to the callback
    * hint 4: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
    */</span>
</code></pre></div></div>
<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 21: register the second callback for this event. */</span>
    <span class="kt">int</span> <span class="n">error</span> <span class="o">=</span> <span class="n">echo_reg_callback</span><span class="p">(</span><span class="n">callback_handler_2</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
    <span class="n">ZF_LOGF_IF</span><span class="p">(</span><span class="n">error</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="s">"Failed to register callback"</span><span class="p">);</span>
</code></pre></div>  </div>
</details>

<h4 id="register-a-callback-handler-1">Register a callback handler</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 24: register the original callback handler for this event */</span>
    <span class="cm">/* hint 1: use the function &lt;interface name&gt;_reg_callback()
     * hint 2: register the function "callback_handler_1"
     * hint 3: pass NULL as the extra argument to the callback
     * hint 4: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-events
     */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 24: register the original callback handler for this event */</span>
    <span class="kt">int</span> <span class="n">error</span> <span class="o">=</span> <span class="n">echo_reg_callback</span><span class="p">(</span><span class="n">callback_handler_1</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
    <span class="n">ZF_LOGF_IF</span><span class="p">(</span><span class="n">error</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">,</span> <span class="s">"Failed to register callback"</span><span class="p">);</span>
</code></pre></div>  </div>
</details>

<hr />

<h3 id="dataports">Dataports</h3>
<p>Dataports are typed shared memory mappings. In your
CAmkES ADL specification, you state what C data type you’ll be using to
access the data in the shared memory – so you can specify a C struct
type, etc.</p>

<p>The really neat part is more that CAmkES provides access control for
accessing these shared memory mappings: if a shared mem mapping is such
that one party writes and the other reads and never writes, we can tell
CAmkES about this access constraint in ADL.</p>

<p>So in TASKs 2 and 4, you’re first being led to create the “Dataport”
interface instances on each of the components that will be participating
in the shared mem communication. We will then link them together using a
“seL4SharedData” connector later on.</p>

<h4 id="specify-dataport-interfaces">Specify dataport interfaces</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 2: the dataport interfaces */
    /* hint 1: specify 3 interfaces: one of type "Buf", one of type "str_buf_t" and one of type "ptr_buf_t"
     * hint 2: for the definition of these types see "str_buf.h".
     * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 2: the dataport interfaces */
    dataport Buf d;
    dataport str_buf_t d_typed;
    dataport ptr_buf_t d_ptrs;
</code></pre></div>  </div>

</details>

<h4 id="specify-dataport-interfaces-1">Specify dataport interfaces</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 4: the dataport interfaces */
    /* hint 1: specify 3 interfaces: one of type "Buf", one of type "str_buf_t" and one of type "ptr_buf_t"
     * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 4: the dataport interfaces */
    dataport Buf d;
    dataport str_buf_t d_typed;
    dataport ptr_buf_t d_ptrs;
</code></pre></div>  </div>
</details>

<h3 id="dataport-connections">Dataport connections</h3>
<p>And here we are: we’re about to specify connections
between the shared memory pages in each client, and tell CAmkES to link
these using shared underlying Frame objects. Fill out this step, and
proceed.</p>

<h4 id="specify-dataport-connections">Specify dataport connections</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 6: Dataport connections */
    /* hint 1: connect the corresponding dataport interfaces of the components to each other
    * hint 2: use seL4SharedData as the connector
    * hint 3: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
    */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 6: Dataport connections */
    connection seL4SharedData data_conn(from client.d, to echo.d);
    connection seL4SharedData typed_data_conn(from client.d_typed, to echo.d_typed);
    connection seL4SharedData ptr_data_conn(from client.d_ptrs, to echo.d_ptrs);
</code></pre></div>  </div>
</details>

<h3 id="access-and-manipulate-share-memory-mapping-dataport-of-the-client">Access and manipulate share memory mapping (Dataport) of the client</h3>
<p>These steps are asking you to write some C code
to access and manipulate the data in the shared memory mapping
(Dataport) of the client. Follow through to the next step.</p>

<h4 id="copy-strings-to-an-untyped-dataport">Copy strings to an untyped dataport</h4>
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 9: copy strings to an untyped dataport */</span>
    <span class="cm">/* hint 1: use the "Buf" dataport as defined in the Client.camkes file
     * hint 2: to access the dataport use the interface name as defined in Client.camkes.
     * For example if you defined it as "dataport Buf d" then you would use "d" to refer to the dataport in C.
     * hint 3: first write the number of strings (NUM_STRINGS) to the dataport
     * hint 4: then copy all the strings from "s_arr" to the dataport.
     * hint 5: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
     */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 9: copy strings to an untyped dataport */</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">n</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="o">*</span><span class="p">)</span><span class="n">d</span><span class="p">;</span>
    <span class="o">*</span><span class="n">n</span> <span class="o">=</span> <span class="n">NUM_STRINGS</span><span class="p">;</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">str</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">NUM_STRINGS</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">strcpy</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="n">s_arr</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
        <span class="n">str</span> <span class="o">+=</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
    <span class="p">}</span>
</code></pre></div>  </div>
</details>

<h4 id="read-the-reply-data-from-a-typed-dataport">Read the reply data from a typed dataport</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 12: read the reply data from a typed dataport */
    /* hint 1: use the "str_buf_t" dataport as defined in the Client.camkes file
     * hint 2: to access the dataport use the interface name as defined in Client.camkes.
     * For example if you defined it as "dataport str_buf_t d_typed" then you would use "d_typed" to refer to the dataport in C.
     * hint 3: for the definition of "str_buf_t" see "str_buf.h".
     * hint 4: use the "n" field to determine the number of strings in the dataport
     * hint 5: print out the specified number of strings from the "str" field
     * hint 6: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 12: read the reply data from a typed dataport */
    for (int i = 0; i &lt; d_typed-&gt;n; i++) {
        printf("%s: string %d (%p): \"%s\"\n", get_instance_name(), i, d_typed-&gt;str[i], d_typed-&gt;str[i]);
    }
</code></pre></div>  </div>
</details>

<h4 id="send-data-using-dataports">Send data using dataports</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  /* TASK 13: send the data over again, this time using two dataports, one
     * untyped dataport containing the data, and one typed dataport containing
     * dataport pointers pointing to data in the untyped, dataport.
     */
    /* hint 1: for the untyped dataport use the "Buf" dataport as defined in the Client.camkes file
     * hint 2: for the typed dataport use the "ptr_buf_t" dataport as defined in the Client.camkes file
     * hint 3: for the definition of "ptr_buf_t" see "str_buf.h".
     * hint 4: copy all the strings from "s_arr" into the untyped dataport
     * hint 5: use the "n" field of the typed dataport to specify the number of dataport pointers (NUM_STRINGS)
     * hint 6: use the "ptr" field of the typed dataport to store the dataport pointers
     * hint 7: use the function "dataport_wrap_ptr()" to create a dataport pointer from a regular pointer
     * hint 8: the dataport pointers should point into the untyped dataport
     * hint 9: for more information about dataport pointers see: https://github.com/seL4/camkes-tool/blob/master/docs/index.md
     */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 13: send the data over again, this time using two dataports, one
     * untyped dataport containing the data, and one typed dataport containing
     * dataport pointers pointing to data in the untyped, dataport.
     */</span>
    <span class="n">d_ptrs</span><span class="o">-&gt;</span><span class="n">n</span> <span class="o">=</span> <span class="n">NUM_STRINGS</span><span class="p">;</span>
    <span class="n">str</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)</span><span class="n">d</span><span class="p">;</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">NUM_STRINGS</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">strcpy</span><span class="p">(</span><span class="n">str</span><span class="p">,</span> <span class="n">s_arr</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
        <span class="n">d_ptrs</span><span class="o">-&gt;</span><span class="n">ptr</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">dataport_wrap_ptr</span><span class="p">(</span><span class="n">str</span><span class="p">);</span>
        <span class="n">str</span> <span class="o">+=</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
    <span class="p">}</span>
</code></pre></div>  </div>
</details>

<h3 id="access-and-manipulate-share-memory-mapping-dataport-of-the-server">Access and manipulate share memory mapping (Dataport) of the server</h3>
<p>And these steps are asking you to write some C
code to access and manipulate the data in the shared memory mapping
(Dataport) of the server.</p>

<h4 id="read-data-from-an-untyped-dataport">Read data from an untyped dataport</h4>
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 19: read some data from the untyped dataport */</span>
  <span class="cm">/* hint 1: use the "Buf" dataport as defined in the Echo.camkes file
    * hint 2: to access the dataport use the interface name as defined in Echo.camkes.
    * For example if you defined it as "dataport Buf d" then you would use "d" to refer to the dataport in C.
    * hint 3: first read the number of strings from the dataport
    * hint 4: then print each string from the dataport
    * hint 5: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
    */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="cm">/* TASK 19: read some data from the untyped dataport */</span>
    <span class="kt">int</span> <span class="o">*</span><span class="n">n</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="o">*</span><span class="p">)</span><span class="n">d</span><span class="p">;</span>
    <span class="kt">char</span> <span class="o">*</span><span class="n">str</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="o">*</span><span class="n">n</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">printf</span><span class="p">(</span><span class="s">"%s: saying (%p): </span><span class="se">\"</span><span class="s">%s</span><span class="se">\"\n</span><span class="s">"</span><span class="p">,</span> <span class="n">get_instance_name</span><span class="p">(),</span> <span class="n">str</span><span class="p">,</span> <span class="n">str</span><span class="p">);</span>
      <span class="n">str</span> <span class="o">+=</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
    <span class="p">}</span>
</code></pre></div>  </div>
</details>

<h4 id="put-data-into-a-typed-dataport">Put data into a typed dataport</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 20: put a modified copy of the data from the untyped dataport into the typed dataport */</span>
    <span class="cm">/* hint 1: modify each string by making it upper case, use the function "uppercase"
     * hint 2: read from the "Buf" dataport as above
     * hint 3: write to the "str_buf_t" dataport as defined in the Echo.camkes file
     * hint 4: to access the dataport use the interface name as defined in Echo.camkes.
     * For example if you defined it as "dataport str_buf_t d_typed" then you would use "d_typed" to refer to the dataport in C.
     * hint 5: for the definition of "str_buf_t" see "str_buf.h"
     * hint 6: use the "n" field to specify the number of strings in the dataport
     * hint 7: copy the specified number of strings from the "Buf" dataport to the "str" field
     * hint 8: look at https://github.com/seL4/camkes-tool/blob/master/docs/index.md#an-example-of-dataports
     * hint 9: you could combine this TASK with the previous one in a single loop if you want
     */</span>
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 20: put a modified copy of the data from the untyped dataport into the typed dataport */</span>
    <span class="n">n</span> <span class="o">=</span> <span class="p">(</span><span class="kt">int</span><span class="o">*</span><span class="p">)</span><span class="n">d</span><span class="p">;</span>
    <span class="n">str</span> <span class="o">=</span> <span class="p">(</span><span class="kt">char</span><span class="o">*</span><span class="p">)(</span><span class="n">n</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="n">j</span> <span class="o">=</span> <span class="o">*</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="o">*</span><span class="n">n</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">,</span> <span class="n">j</span><span class="o">--</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">strncpy</span><span class="p">(</span><span class="n">d_typed</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">[</span><span class="n">j</span><span class="p">],</span> <span class="n">str</span><span class="p">,</span> <span class="n">STR_LEN</span><span class="p">);</span>
        <span class="n">uppercase</span><span class="p">(</span><span class="n">d_typed</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">[</span><span class="n">j</span><span class="p">]);</span>
        <span class="n">str</span> <span class="o">+=</span> <span class="n">strlen</span><span class="p">(</span><span class="n">str</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="n">d_typed</span><span class="o">-&gt;</span><span class="n">n</span> <span class="o">=</span> <span class="o">*</span><span class="n">n</span><span class="p">;</span>
</code></pre></div>  </div>
</details>

<h4 id="read-data-from-a-typed-dataport">Read data from a typed dataport</h4>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 23: read some data from the dataports. specifically:
    * read a dataport pointer from one of the typed dataports, then use
    * that pointer to access data in the untyped dataport.
    */</span>
  <span class="cm">/* hint 1: for the untyped dataport use the "Buf" dataport as defined in the Echo.camkes file
    * hint 2: for the typed dataport use the "ptr_buf_t" dataport as defined in the Echo.camkes file
    * hint 3: for the definition of "ptr_buf_t" see "str_buf.h".
    * hint 4: the "n" field of the typed dataport specifies the number of dataport pointers
    * hint 5: the "ptr" field of the typed dataport contains the dataport pointers
    * hint 6: use the function "dataport_unwrap_ptr()" to create a regular pointer from a dataport pointer
    * hint 7: for more information about dataport pointers see: https://github.com/seL4/camkes-tool/blob/master/docs/index.md
    * hint 8: print out the string pointed to by each dataport pointer
    */</span>
</code></pre></div></div>
<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  <span class="cm">/* TASK 23: read some data from the dataports. specifically:
    * read a dataport pointer from one of the typed dataports, then use
    * that pointer to access data in the untyped dataport.
    */</span>
  <span class="kt">char</span> <span class="o">*</span><span class="n">str</span><span class="p">;</span>
  <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">d_ptrs</span><span class="o">-&gt;</span><span class="n">n</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
      <span class="n">str</span> <span class="o">=</span> <span class="n">dataport_unwrap_ptr</span><span class="p">(</span><span class="n">d_ptrs</span><span class="o">-&gt;</span><span class="n">ptr</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
      <span class="n">printf</span><span class="p">(</span><span class="s">"%s: dptr saying (%p): </span><span class="se">\"</span><span class="s">%s</span><span class="se">\"\n</span><span class="s">"</span><span class="p">,</span> <span class="n">get_instance_name</span><span class="p">(),</span> <span class="n">str</span><span class="p">,</span> <span class="n">str</span><span class="p">);</span>
  <span class="p">}</span>
</code></pre></div>  </div>
</details>

<h3 id="camkes-attributes">CAmkES attributes</h3>
<p>This is an introduction to CAmkES attributes: you’re
being asked to set the priority of the components.</p>

<h4 id="set-component-priorities">Set component priorities</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 7: set component priorities */
    /* hint 1: component priority is specified as an attribute with the name &lt;component name&gt;.priority
    * hint 2: the highest priority is represented by 255, the lowest by 0
    */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 7: set component priorities */
    client.priority = 255;
    echo.priority = 254;
</code></pre></div>  </div>
</details>

<h3 id="specify-the-data-access-constraints-for-dataports">Specify the data access constraints for Dataports</h3>
<p>This is where we specify the data access constraints
for the Dataports in a shared memory connection. We then go about
attempting to violate those constraints to see how CAmkES has truly met
our constraints when mapping those Dataports.</p>

<h4 id="restrict-access-to-dataports">Restrict access to dataports</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 8: restrict access to dataports */
    /* hint 1: use attribute &lt;component&gt;.&lt;interface_name&gt;_access for each component and interface
    * hint 2: appropriate values for the to_access and from_access attributes are: "R" or "W"
    * hint 4: make the "Buf" dataport read only for the Echo component
    * hint 3: make the "str_buf_t" dataport read only for the Client component
    */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 8: restrict access to dataports */
    echo.d_access = "R";
    client.d_access = "W";
    echo.d_typed_access = "W";
    client.d_typed_access = "R";
</code></pre></div>  </div>
</details>

<h4 id="test-the-read-and-write-permissions-on-the-dataport">Test the read and write permissions on the dataport</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 16: test the read and write permissions on the dataport.
    * When we try to write to a read-only dataport, we will get a VM fault.
    */
    /* hint 1: try to assign a value to a field of the "str_buf_t" dataport */
</code></pre></div></div>

<details>
  <summary><em>Quick solution</em></summary>

  <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    /* TASK 16: test the read and write permissions on the dataport.
    * When we try to write to a read-only dataport, we will get a VM fault.
    */
    d_typed-&gt;n = 0;
</code></pre></div>  </div>
</details>

<h2 id="done">Done!</h2>
<p>Congratulations: be sure to read up on the keywords and
structure of ADL: it’s key to understanding CAmkES. And well done on
writing your first CAmkES application.</p>



<p style="text-align: right;">

      Next: <a href="/Tutorials/hello-camkes-timer">CAmkES timer tutorial</a>
</p>

<hr>
    <p><em>Tutorial included from <a href="https://github.com/sel4/sel4-tutorials/blob/master/tutorials/hello-camkes-2/hello-camkes-2.md">github repo</a> <a href="https://github.com/sel4/sel4-tutorials/edit/master/tutorials/hello-camkes-2/hello-camkes-2.md">edit</a></em></p>
  </div>

  
    
<div class="sidebar-toc hidden-xs hidden-sm col-md-3 col-lg-3">
    <ul id="toc" class="section-nav">
<li class="toc-entry toc-h2"><a href="#prerequisites">Prerequisites</a></li>
<li class="toc-entry toc-h2"><a href="#capdl-loader">CapDL Loader</a></li>
<li class="toc-entry toc-h2"><a href="#initialising">Initialising</a>
<ul>
<li class="toc-entry toc-h3"><a href="#specify-an-events-interface">Specify an events interface</a>
<ul>
<li class="toc-entry toc-h4"><a href="#specify-an-events-interface-1">Specify an events interface</a></li>
<li class="toc-entry toc-h4"><a href="#add-connections">Add connections</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#data">Data</a>
<ul>
<li class="toc-entry toc-h4"><a href="#signal-that-the-data-is-available">Signal that the data is available</a></li>
<li class="toc-entry toc-h4"><a href="#wait-for-data-to-become-available">Wait for data to become available</a></li>
<li class="toc-entry toc-h4"><a href="#signal-that-data-is-available">Signal that data is available</a></li>
<li class="toc-entry toc-h4"><a href="#wait-for-data-to-be-read">Wait for data to be read</a></li>
<li class="toc-entry toc-h4"><a href="#signal-that-data-is-available-1">Signal that data is available</a></li>
<li class="toc-entry toc-h4"><a href="#signal-that-data-has-been-read">Signal that data has been read</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#handle-notifications">Handle notifications</a>
<ul>
<li class="toc-entry toc-h4"><a href="#register-a-callback-handler">Register a callback handler</a></li>
<li class="toc-entry toc-h4"><a href="#register-another-callback-handler">Register another callback handler</a></li>
<li class="toc-entry toc-h4"><a href="#register-a-callback-handler-1">Register a callback handler</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#dataports">Dataports</a>
<ul>
<li class="toc-entry toc-h4"><a href="#specify-dataport-interfaces">Specify dataport interfaces</a></li>
<li class="toc-entry toc-h4"><a href="#specify-dataport-interfaces-1">Specify dataport interfaces</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#dataport-connections">Dataport connections</a>
<ul>
<li class="toc-entry toc-h4"><a href="#specify-dataport-connections">Specify dataport connections</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#access-and-manipulate-share-memory-mapping-dataport-of-the-client">Access and manipulate share memory mapping (Dataport) of the client</a>
<ul>
<li class="toc-entry toc-h4"><a href="#copy-strings-to-an-untyped-dataport">Copy strings to an untyped dataport</a></li>
<li class="toc-entry toc-h4"><a href="#read-the-reply-data-from-a-typed-dataport">Read the reply data from a typed dataport</a></li>
<li class="toc-entry toc-h4"><a href="#send-data-using-dataports">Send data using dataports</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#access-and-manipulate-share-memory-mapping-dataport-of-the-server">Access and manipulate share memory mapping (Dataport) of the server</a>
<ul>
<li class="toc-entry toc-h4"><a href="#read-data-from-an-untyped-dataport">Read data from an untyped dataport</a></li>
<li class="toc-entry toc-h4"><a href="#put-data-into-a-typed-dataport">Put data into a typed dataport</a></li>
<li class="toc-entry toc-h4"><a href="#read-data-from-a-typed-dataport">Read data from a typed dataport</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#camkes-attributes">CAmkES attributes</a>
<ul>
<li class="toc-entry toc-h4"><a href="#set-component-priorities">Set component priorities</a></li>
</ul>
</li>
<li class="toc-entry toc-h3"><a href="#specify-the-data-access-constraints-for-dataports">Specify the data access constraints for Dataports</a>
<ul>
<li class="toc-entry toc-h4"><a href="#restrict-access-to-dataports">Restrict access to dataports</a></li>
<li class="toc-entry toc-h4"><a href="#test-the-read-and-write-permissions-on-the-dataport">Test the read and write permissions on the dataport</a></li>
</ul>
</li>
</ul>
</li>
<li class="toc-entry toc-h2"><a href="#done">Done!</a></li>
</ul>
</div>

  
</div>
<script src="/assets/js/toggle-markdown.js"></script>

    </main>
    


<footer class="site-footer">

  <h2 class="footer-heading">seL4 docs</h2>

  <div class="footer-col-wrapper">

    <div class="col-md-2">
      



<ul class="social-media-list">
  <li><a href="https://github.com/sel4"><i class="fab fa-github"></i> <span class="username">sel4</span></a></li><li><a href="https://github.com/sel4proj"><i class="fab fa-github"></i> <span class="username">sel4proj</span></a></li>
</ul>

    </div>

    <div class="col-md-8">
      <ul class="list-unstyled">
        <li>
          This site is for displaying seL4 related documentation.  Pull requests are welcome.
        </li>
        
          <li>
            Site last updated: Fri Feb 7 10:17:38 2025 +1100 ee78c8857c
          </li>
          <li>
                Page last updated: Mon Jan 6 18:52:01 2025 +1100 df31e5ccb8
          </li>
        
      </ul>
    </div>
    <div class="col-md-2">
<a href="https://github.com/seL4/docs/blob/master/Tutorials/hello-camkes-2.md">View page on GitHub</a>
      <br />
      <a href="https://github.com/seL4/docs/edit/master/Tutorials/hello-camkes-2.md">Edit page on GitHub</a>
      <br />
      <a href="/sitemap">Sitemap</a>
    </div>

  </div>

</footer>

  </body>
</html>
